package org.meb.speedway.model.registry;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Entity
@Table(name = "t_team", uniqueConstraints = @UniqueConstraint(name = "TEAM_NAME_UK",
		columnNames = "name"))
@Getter
@Setter
@NoArgsConstructor
@RequiredArgsConstructor
@ToString(exclude = "ridersHistory")
public class Team implements Serializable {

	private static final long serialVersionUID = 1659366484449762354L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Version
	private Long version;

	@NonNull
	@Column(length = 100, nullable = false)
	private String name;

	@OneToMany(mappedBy = "team")
	private List<TeamRiderHistory> ridersHistory;
}